#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
int n;
int a[100005];
int b[100005];
long long  ret;//逆序对个数

void msort( int l, int r)
{
    if (l >= r)return;
    int mid = (l + r) >> 1;
    msort( l, mid);  
    msort( mid + 1, r);  
    int i = l; int j = mid + 1; int k = l;
    while (i <= mid && j <= r)
    {
        if (a[i] > a[j])
        {
            ret += mid - i + 1;
            b[k++] = a[j++];
        }
        else
        {
            b[k++] = a[i++];
        }
    }
    while (i <= mid)b[k++] = a[i++];
    while (j <= r)b[k++] = a[j++];
    //拷贝到原来的数组
    for (int i = l; i <= r; i++)
    {
        a[i] = b[i];
    }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[i];  
    //归并排序
    msort(0, n - 1);
    cout << ret << endl;
    return 0;
}
